set more off
set matsize 1000

use taxi.dta, clear

** Table A1: Summary Statistics **

*Panel A
estpost sum female
mat A = (e(mean)*100 \ J(1,1,.))'
estpost sum age experience days hours rides income road_familiar mapuse 
mat A = A\ (e(mean) \ J (1,8,.) )'
local rowname : rownames A

estpost tab mapuse, nototal
mat A = A\ (J (1,4,.) \ e(pct))'
mat colname A = "Mean" "%" 
mat rowname A = `rowname' "never" "sometimes" "frequently" "always" 

*Panel B
estpost ttest affect_driving_agree focus_agree distract_agree save_time_agree ///
relaxed_agree earn_more_agree tired_agree find_way_agree english_agree ///
smartphone_agree, by(map_dummy)
mat B = (e(mu_2)*100 \ e(mu_1)*100 )'

mat D = J(1,1,.)
foreach var of varlist affect_driving focus distract save_time relaxed earn_more tired find_way english smartphone {
estpost tab map_dummy `var', chi2
mat D = D \ e(p)'
}
mat B = B,D[2..11,1]
mat colname B = "Use map apps" "Never use map apps" "Pearson Chi2 p-value" 

*Panel C
estpost tab counter_rides counter_hours if map_dummy == 1
mat C = e(pct)'
estpost tab counter_rides counter_hours if map_dummy == 0
mat C = C, e(pct)'

mat C = C[4,1...]\C[1,1...]\C[3,1...]\C[2,1...] ///
          \C[12,1...]\C[9,1...]\C[11,1...]\C[10,1...] ///
		  \C[8,1...]\C[5,1...]\C[7,1...]\C[6,1...]
mat colname C = "Without map app" "With map app" 

estpost ttest age, by(map_dummy)
mat E = (e(N_2), e(N_1))	 
mat rowname E = "obs"
mat C = C\E

estout m(A, fmt(1 2)) using "TableA1.xls", label replace 

estout m(B, fmt(1 1 2)) using "TableA1.xls", label append 

estout m(C, fmt(1 1)) using "TableA1.xls", label append 



**Table A2. Use of map app
 

global outopt plain coljust(lc) var starloc(1) starlevels(10 5 1) ///
	 landscape stats(b p) bdec(3) tdec(3)
	

outreg, clear(mapuse_logit)

ologit mapuse wrongturn_z2 age_demean smartphone_z2, robust
outreg, keep(wrongturn_z2 age_demean smartphone_z2) merge(mapuse_logit) $outopt ctitle("Variables" "(a) Wrong turns")
	
ologit mapuse road_familiar_z2 age_demean smartphone_z2, robust
outreg, keep(road_familiar_z2 age_demean smartphone_z2) merge(mapuse_logit) $outopt ctitle("Variables" "(b) Knowledge of the road")

ologit mapuse affect_driving_z2 age_demean smartphone_z2, robust
outreg, keep(affect_driving_z2 age_demean smartphone_z2) merge(mapuse_logit) $outopt ctitle("Variables" "(c) Inc diff")

ologit mapuse affect_driving_z2 age_demean smartphone_z2 if affect_driving_likert>3, robust
outreg, keep(affect_driving_z2 age_demean smartphone_z2) merge(mapuse_logit) $outopt ctitle("Variables" "(d) Inc diff (sub sample)")

ologit mapuse affect_driving_z2 wrongturn_z2 road_familiar_z2 age_demean smartphone_z2 if affect_driving_likert>3, robust
outreg, keep(wrongturn_z2 affect_driving_z2 road_familiar_z2 age_demean smartphone_z2) merge(mapuse_logit) ///
$outopt ctitle("Variables" "(e) Inc diff (sub sample)")

outreg using "TableA2.doc", keep(wrongturn_z2 road_familiar affect_driving_z2 age_demean smartphone_z2) $outopt replay(mapuse_logit) replace	





